using System;
using System.Collections.Generic;
using System.Text;

namespace org.ngwt.user.client.rpc.core.System
{
    public class DateTime_CustomFieldSerializer
    {
        private static DateTime date1970 = new DateTime(1970, 1, 1);

        public static void deserialize(SerializationStreamReader streamReader,
            DateTime instance)
        {
            // No fields
        }

        public static DateTime instantiate(SerializationStreamReader streamReader)
        {
            long tick = streamReader.readLong();
            tick = tick * 10000;
            TimeSpan span = new TimeSpan(tick);
            return date1970 + span;
        }

        public static void serialize(SerializationStreamWriter streamWriter, DateTime date)
        {
            TimeSpan span = date - date1970;
            streamWriter.writeLong(span.Ticks/10000);
        }
    }
}
